{% extends 'task/_task.html' %}
{% from '_macros.html' import modal_botton %}
{% block ac_book %} active actmore {% endblock %}


{% block head %}
{{ super() }}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style_lq.css') }}">
{% endblock %}


{% block top_bar %}
<a class="btn btn-success" href="{{ url_for('.book_create') }}">+新增</a>
{% endblock %}


{% block show %}
<div class="row container-fluid">
    {% for book in books %}
    <div class="book vertical-layout col-4 col-lg-3">
        {% if book['cover'] %}
            <img src="{{ url_for('getfile', filename=book['cover']) }} " alt="book" style="height: 200px; width: 175px;">
        {% else %}
            <img src="{{ url_for('static', filename='img/fllmt.jpg') }} " alt="book" style="height: 200px; width: 175px;">
        {% endif %}

        <h5><i class="ri-book-open-line"></i>{{ book['name'] }}</h5>
        <div class="book_page">
            <label>已读:{{ book['read_page'] }}/{{ book['page'] }}页</label>
        </div>
        <div class="book_page">
            <i class="ri-medal-line"></i>
            <label>{{ book['percent'] }}%</label>&nbsp;
            <label>{{ book['read_hour'] }}h</label>
        </div>

        <p>
            <a href="{{ url_for('.book_update', book_id=book['id']) }}" class="btn btn-sm btn-primary" role="button">修改</a>
            <a href="{{ url_for('.upload_cover', book_id=book['id']) }}" class="btn btn-sm btn-secondary"
                role="button">封面</a>
            {{ modal_botton(
                id='delete' + [book['id']] | join,
                btn_class='btn-sm btn-danger',
                btn_name='删除', title='提醒',
                body='你确定删除书籍 ' + book['name'] + ' 吗？删除后不可恢复！',
                footer_href=url_for('.book_delete', book_id=book['id'])
            )}}
        </p>
    </div>    
    {% endfor %}
</div>
{% endblock %}
